package com.huasan.www.demon.rest;

import javax.ws.rs.ApplicationPath;

import org.glassfish.jersey.server.ResourceConfig;
import org.glassfish.jersey.server.mvc.jsp.JspMvcFeature;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.huasan.www.demon.rest.util.Constants;

@ApplicationPath("rest")
public class Applications extends ResourceConfig {
	
	private static final Logger logger = LoggerFactory.getLogger(Applications.class);
	
	private static final String ENCODING_GZIP = "gzip";
	
	public Applications(){
		logger.debug("Init jersey...");
		packages(this.getClass().getPackage().getName());
		
		for (String clazz : Constants.FILTER_CLASSES){
			try {
				register(Class.forName(clazz));
			} catch (ClassNotFoundException e) {
				// TODO Auto-generated catch block
				logger.error( "Can not load filter:"+clazz+" "+e.getMessage(), e );
			}
		}
		register(JspMvcFeature.class); // For MVC
//		register(new EncodingFeature(ENCODING_GZIP, GZipEncoder.class));
	}
}